package o;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.LabeledIntent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.share.api.ShareBean;
import com.huawei.hms.framework.network.restclient.dnkeeper.DNKeeperConfig;
import java.util.ArrayList;
import java.util.List;
import o.cwj.c;
import o.cwj.d;
import o.cwj.i;

public class cxm extends cxg {
    private ShareBean ˋ;
    private cxi ॱ;

    public String ˎ() {
        return "#WiseDist.customMore#";
    }

    public boolean ˊ(ShareBean shareBean) {
        if (shareBean.ͺ() != 0 || (shareBean.ˏॱ() & 2) == 2) {
            return false;
        }
        return true;
    }

    public boolean ˏ(cxi o_cxi, LinearLayout linearLayout, LayoutInflater layoutInflater, boolean z, ShareBean shareBean) {
        this.ˋ = shareBean;
        this.ॱ = o_cxi;
        View inflate = layoutInflater.inflate(d.ˊ, null);
        ((TextView) inflate.findViewById(c.ˋ)).setText(i.ॱˋ);
        ((ImageView) inflate.findViewById(c.ॱ)).setImageResource(cwj$b.ˎ);
        linearLayout.addView(inflate);
        inflate.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ cxm ˎ;

            {
                this.ˎ = r1;
            }

            public void onClick(View view) {
                evc.ˊ(view);
                cwr.ॱ.ˋ("MoreShareHandler", "click more share!");
                dgh.onEvent(new dge.d(ContentManager.getInstant().getContext(), i.ˎ).ˏ("04|" + UserSession.getInstance().getUserId() + '|' + this.ˎ.ˋ.ʻ()).ˋ());
                this.ˎ.ˊ();
            }
        });
        return false;
    }

    private void ˊ() {
        Intent intent = new Intent("android.intent.action.SEND");
        intent.setType(DNKeeperConfig.DNKEEPER_CONTENT_TYPE);
        PackageManager packageManager = this.ॱ.ᐝ().getPackageManager();
        if (packageManager != null) {
            List<ResolveInfo> queryIntentActivities = packageManager.queryIntentActivities(intent, 0);
            if (!queryIntentActivities.isEmpty()) {
                String property = System.getProperty("line.separator", "\r\n");
                ArrayList arrayList = new ArrayList();
                List ॱˊ = this.ॱ.ॱˊ();
                for (ResolveInfo resolveInfo : queryIntentActivities) {
                    Intent intent2 = new Intent("android.intent.action.SEND");
                    intent2.setType(DNKeeperConfig.DNKEEPER_CONTENT_TYPE);
                    ActivityInfo activityInfo = resolveInfo.activityInfo;
                    if (!ॱˊ.contains(activityInfo.packageName)) {
                        intent2.setClassName(activityInfo.packageName, activityInfo.name);
                        intent2.setPackage(activityInfo.packageName);
                        if (3 != this.ˋ.ˊॱ() && this.ˋ.ͺ() == 2 && "appdetail".equals(this.ˋ.ʼ())) {
                            String ʻ = this.ˋ.ʻ();
                            String string = this.ॱ.ᐝ().getResources().getString(i.ˊ);
                            Object[] objArr = new Object[]{string, ʻ};
                            string = "android.intent.extra.TEXT";
                            intent2.putExtra(string, this.ॱ.ᐝ().getResources().getString(i.ʻॱ, objArr));
                        } else {
                            intent2.putExtra("android.intent.extra.TEXT", ˎ(this.ॱ.ᐝ(), this.ˋ, activityInfo, property));
                        }
                        arrayList.add(new LabeledIntent(intent2, activityInfo.packageName, resolveInfo.loadLabel(packageManager), resolveInfo.icon));
                    }
                }
                Intent createChooser = Intent.createChooser((Intent) arrayList.remove(0), this.ॱ.ᐝ().getResources().getString(i.ॱॱ));
                if (createChooser != null) {
                    createChooser.putExtra("android.intent.extra.INITIAL_INTENTS", (Parcelable[]) arrayList.toArray(new LabeledIntent[arrayList.size()]));
                    try {
                        this.ॱ.ᐝ().startActivity(createChooser);
                    } catch (ActivityNotFoundException e) {
                        cwr.ॱ.ˊ("MoreShareHandler", "more share ActivityNotFoundException" + e);
                    }
                } else {
                    return;
                }
            }
            this.ॱ.finish();
        }
    }

    private String ˎ(Context context, ShareBean shareBean, ActivityInfo activityInfo, String str) {
        String ॱ = cxw.ॱ(context, shareBean.ʻ(), activityInfo.processName);
        String str2 = "";
        if (3 != shareBean.ˊॱ() && "appdetail".equals(shareBean.ʼ())) {
            str2 = this.ॱ.ᐝ().getResources().getString(i.ˊ);
            return context.getString(i.ˊˊ, new Object[]{str2}) + ॱ;
        } else if (TextUtils.isEmpty(shareBean.ˊ())) {
            return ॱ;
        } else {
            return shareBean.ˊ() + str + ॱ;
        }
    }

    public void ˎ(ShareBean shareBean) {
    }

    public void ˏ() {
    }

    public void ॱ() {
    }

    public boolean ˋ() {
        return false;
    }
}
